package bocchi.character;

import bocchi.BocchiCore;
import bocchi.card.*;
import bocchi.general.ResourcePath;
import bocchi.patch.PlayerEnum;
import basemod.abstracts.CustomPlayer;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.EnergyManager;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.cutscenes.CutscenePanel;
import com.megacrit.cardcrawl.events.city.Vampires;
import com.megacrit.cardcrawl.helpers.FontHelper;
import com.megacrit.cardcrawl.helpers.ScreenShake;
import com.megacrit.cardcrawl.localization.CharacterStrings;
import com.megacrit.cardcrawl.relics.Vajra;
import com.megacrit.cardcrawl.screens.CharSelectInfo;

import java.util.ArrayList;

public class Hitori extends CustomPlayer {
    public static final String ID = Hitori.class.getSimpleName();

    private static final String SHOULDER_1 = ResourcePath.CHARACTER + "shoulder1.png";
    private static final String SHOULDER_2 = ResourcePath.CHARACTER + "shoulder2.png";
    private static final String CORPSE = ResourcePath.CHARACTER + "corpse.png";
    private static final String CHARACTER = ResourcePath.CHARACTER + "character.png";

    private static final String VFX = ResourcePath.ORB + "vfx.png";
    private static final String[] ORB_TEXTURES = new String[]{
            ResourcePath.ORB + "layer5.png",
            ResourcePath.ORB + "layer4.png",
            ResourcePath.ORB + "layer3.png",
            ResourcePath.ORB + "layer2.png",
            ResourcePath.ORB + "layer1.png",
            ResourcePath.ORB + "layer6.png",
            ResourcePath.ORB + "layer5d.png",
            ResourcePath.ORB + "layer4d.png",
            ResourcePath.ORB + "layer3d.png",
            ResourcePath.ORB + "layer2d.png",
            ResourcePath.ORB + "layer1d.png"
    };
    private static final float[] LAYER_SPEEDS = new float[]{-40.0F, -32.0F, 20.0F, -20.0F, 0.0F, -10.0F, -8.0F, 5.0F, -5.0F, 0.0F};
    private static final CharacterStrings STRINGS = CardCrawlGame.languagePack.getCharacterString(BocchiCore.getGameID(ID));
    private static final String NAME = STRINGS.NAMES[0];
    private static final String FLAVOR_TEXT = STRINGS.TEXT[0];
    private static final String HEART_TEXT = STRINGS.TEXT[1];

    private static final int STRIKE_NUM = 4;
    private static final int DEFEND_NUM = 4;

    public Hitori(String name) {
        super(name, PlayerEnum.Hitori, ORB_TEXTURES, VFX, LAYER_SPEEDS, null, null);
        this.dialogX = (this.drawX + 0.0F * Settings.scale);
        this.dialogY = (this.drawY + 150.0F * Settings.scale);

        this.initializeClass(
                CHARACTER,
                SHOULDER_2,
                SHOULDER_1,
                CORPSE,
                this.getLoadout(),
                0.0F,
                0.0F,
                200.0F,
                220.0F,
                new EnergyManager(3)
        );
    }

    public static String getGameID(String ID) {
        return "Hitori:" + ID;
    }

    public ArrayList<String> getStartingDeck() {
        ArrayList<String> startingDeck = new ArrayList<>();

        for (int i = 0; i < STRIKE_NUM; i++) {
            startingDeck.add(Strike.GAME_ID);
        }

        for (int i = 0; i < DEFEND_NUM; i++) {
            startingDeck.add(Defend.GAME_ID);
        }

        startingDeck.add(Inkya.GAME_ID);
        startingDeck.add(DailyPractice.GAME_ID);
        return startingDeck;
    }

    public ArrayList<String> getStartingRelics() {
        ArrayList<String> retVal = new ArrayList<>();
        retVal.add(Vajra.ID);
        return retVal;
    }

    public CharSelectInfo getLoadout() {
        return new CharSelectInfo(
                NAME,
                FLAVOR_TEXT,
                75,
                75,
                0,
                99,
                5,
                this,
                this.getStartingRelics(),
                this.getStartingDeck(),
                false
        );
    }

    @Override
    public String getTitle(PlayerClass playerClass) {
        return NAME;
    }

    @Override
    public AbstractCard.CardColor getCardColor() {
        return PlayerEnum.HITORI_PINK;
    }

    @Override
    public AbstractCard getStartCardForEvent() {
        return new Strike();
    }

    @Override
    public Color getCardTrailColor() {
        return Characters.HITORI_COLOR;
    }

    @Override
    public int getAscensionMaxHPLoss() {
        return 5;
    }

    @Override
    public BitmapFont getEnergyNumFont() {
        return FontHelper.energyNumFontBlue;
    }

    @Override
    public void doCharSelectScreenSelectEffect() {
        CardCrawlGame.screenShake.shake(ScreenShake.ShakeIntensity.MED, ScreenShake.ShakeDur.SHORT, false);
    }

    @Override
    public ArrayList<CutscenePanel> getCutscenePanels() {
        ArrayList<CutscenePanel> panels = new ArrayList<>();
        panels.add(new CutscenePanel(ResourcePath.CHARACTER + "victory1.png", "ATTACK_MAGIC_FAST_1"));
        panels.add(new CutscenePanel(ResourcePath.CHARACTER + "victory2.png"));
        panels.add(new CutscenePanel(ResourcePath.CHARACTER + "victory3.png"));
        return panels;
    }

    @Override
    public String getCustomModeCharacterButtonSoundKey() {
        return "ATTACK_HEAVY";
    }

    @Override
    public String getLocalizedCharacterName() {
        return STRINGS.NAMES[0];
    }

    @Override
    public AbstractPlayer newInstance() {
        return new Hitori(this.name);
    }

    @Override
    public String getSpireHeartText() {
        return HEART_TEXT;
    }

    @Override
    public Color getSlashAttackColor() {
        return Characters.HITORI_COLOR;
    }

    @Override
    public String getVampireText() {
        return Vampires.DESCRIPTIONS[1];
    }

    @Override
    public Color getCardRenderColor() {
        return Characters.HITORI_COLOR;
    }

    @Override
    public AbstractGameAction.AttackEffect[] getSpireHeartSlashEffect() {
        return new AbstractGameAction.AttackEffect[]{AbstractGameAction.AttackEffect.SLASH_HEAVY, AbstractGameAction.AttackEffect.FIRE, AbstractGameAction.AttackEffect.SLASH_DIAGONAL, AbstractGameAction.AttackEffect.SLASH_HEAVY, AbstractGameAction.AttackEffect.FIRE, AbstractGameAction.AttackEffect.SLASH_DIAGONAL};
    }
}
